//
//  TabBarController.m
//  Hui
//
//  Created by HawkingWang on 16/10/26.
//  Copyright © 2016年 Hui. All rights reserved.
//

#import "TabBarController.h"
#import "GetOrderViewController.h"
#import "DeliveryViewController.h"
#import "PublishViewController.h"

#define Title @[@"立即抢单", @"我的配送", @"我的发布"]
#define Image @[@"bar-q", @"bar-s", @"bar-f"]
#define SelectedImage @[@"bar-q-touch", @"bar-s-touch", @"bar-f-touch"]

@interface TabBarController ()

@end

@implementation TabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    [self setTabBar];
    
    [self tabBarSetting];
    
}

- (void)setTabBar{
    GetOrderViewController *get = [[GetOrderViewController alloc] init];
    DeliveryViewController *delivery = [[DeliveryViewController alloc] init];
    PublishViewController *publish = [[PublishViewController alloc] init];
    
    NSArray *controllerArray = @[get, delivery, publish];
    NSMutableArray *navArray = [NSMutableArray array];
    
    for (int i = 0; i < controllerArray.count; i++) {
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controllerArray[i]];
        
        nav.navigationBar.barTintColor = APPCOLOR;
        nav.navigationBar.tintColor = [UIColor whiteColor];
        nav.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName: [UIFont fontWithName:APPFONT size:19]};
        nav.navigationBar.translucent = NO;
        //导航栏透明
        UIImage *image = [[UIImage alloc] init];
        [nav.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
        //去掉黑线
        nav.navigationBar.shadowImage = image;
        
        UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:Title[i] image:[UIImage imageNamed:Image[i]] selectedImage:[UIImage imageNamed:SelectedImage[i]]];
        
        nav.tabBarItem = item;
        
        [navArray addObject:nav];
    }
    
    self.viewControllers = navArray;
}

- (void)tabBarSetting{
    self.tabBar.barStyle = UIBarStyleBlack;
    self.tabBar.translucent = YES;
    self.tabBar.barTintColor = RGBACOLOR(255, 255, 255, 0.8);
    self.tabBar.tintColor = APPCOLOR;
    
    //设置tabbar背景颜色
    UIImage *image = [[UIImage alloc] init];
    [[UITabBar appearance] setBackgroundColor:RGBACOLOR(255, 255, 255, 1)];
    [[UITabBar appearance] setBackgroundImage:image];
    [[UITabBar appearance] setShadowImage:image];
    UIView *tabLine = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.5)];
    tabLine.backgroundColor = RGBACOLOR(178, 178, 178, 0.5);
    [self.tabBar addSubview:tabLine];
    
//    UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
//    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
//    effectView.frame = CGRectMake( 0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64);
//    [self addSubview:effectView];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
